
package com.limoilux.cobolux.core;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;


public class ProjectCreator extends RessourceCreator
{
	private final IProjectNature nature;
	private String name;

	public ProjectCreator()
	{
		this.nature = new CoboluxNature();
	}

	public boolean setName(String name)
	{
		this.name = name;
		return true;
	}

	@Override
	public void create(IProgressMonitor monitor, IWorkspaceRoot root) throws CoreException
	{
		IProject project = null;

		project = root.getProject(this.name);
		monitor.beginTask("Creating project", 3);
		project.create(monitor);
		monitor.worked(1);

		monitor.setTaskName("opening project...");
		project.open(monitor);
		monitor.worked(1);

		monitor.setTaskName("configuring project...");
		this.nature.setProject(project);
		this.nature.configure();
		monitor.worked(1);
	}

}
